
Namespace Validation
    <AttributeUsage(AttributeTargets.Property, AllowMultiple:=True, Inherited:=False)> Public NotInheritable Class ComparePropertyValidatorAttribute
        Inherits BaseValidatorAttribute

#Region " Declarations "

        Private _enumComparisonType As ComparisonType = ComparisonType.Equal
        Private _enumRequiredEntry As RequiredEntry = RequiredEntry.No
        Private _strCompareToPropertyName As String = String.Empty

#End Region

#Region " Properties "

        Public ReadOnly Property CompareToPropertyName() As String
            Get
                Return _strCompareToPropertyName
            End Get
        End Property

        Public ReadOnly Property ComparisonType() As ComparisonType
            Get
                Return _enumComparisonType
            End Get
        End Property

        Public ReadOnly Property RequiredEntry() As RequiredEntry
            Get
                Return _enumRequiredEntry
            End Get
        End Property

#End Region

#Region " Constructor "

        Public Sub New(ByVal enumComparisonType As ComparisonType, ByVal strCompareToPropertyName As String, ByVal enumRequiredEntry As RequiredEntry)
            _enumComparisonType = enumComparisonType
            _strCompareToPropertyName = strCompareToPropertyName
            _enumRequiredEntry = enumRequiredEntry
        End Sub

#End Region

#Region " Methods "

        Public Overrides Function Create(ByVal strPropertyName As String) As Validator
            Return New Validator(AddressOf Validation.ComparisonValidationRules.ComparePropertyRule, New ComparePropertyRuleEventArgs(Me, strPropertyName), RuleType.Attribute)
        End Function

#End Region

    End Class

End Namespace
